import React, { useEffect, useState } from 'react'
// connect返回一个父组件
import { connect } from 'react-redux'
function Count(props) {
  const { count, dispatch } = props

  return (
    <div>
      <p>{count}</p>
      <button
        onClick={() => {
          dispatch({ type: 'add', payload: 3 })
        }}
      >
        +n
      </button>
    </div>
  )
}

function mapStateToProps(state) {
  // state 是store对象的state(所有数据)
  return {
    count: state.count,
  }
}
export default connect(mapStateToProps)(Count)

/*
  function xxx(){
    return class Far extends Compeonent{
    }
  }
  function connect(mapStateToProps){
   const obj =  mapStateToProps(store.getState())
   return () => {
     return class Far extends Compeonent{
        render(){
          return <子组件 {...obj}/>
        }
    }
   }
  }


*/
